package com.hmily.dubbo.provider.impl;

import com.hmily.dubbo.api.UserValidationFacade;
import com.hmily.dubbo.api.bean.ValidateUserInfo;
import org.apache.dubbo.rpc.RpcContext;

/**
 * <h1>用户校验实现类逻辑。</h1>
 *
 * @author hmilyylimh
 *         ^_^
 * @version 0.0.1
 *         ^_^
 * @date 2021-11-07
 *
 */
public class UserValidationFacadeImpl implements UserValidationFacade {

    @Override
    public ValidateUserInfo validateUser(ValidateUserInfo userInfo) {
        int localPort = RpcContext.getContext().getLocalPort();
        System.out.println("recv, userInfo " + userInfo + ", port = " + localPort);

        // 针对入参做一些简单的赋值操作，模拟进行了业务逻辑处理
        userInfo.setId(localPort + "----" + userInfo.getId());
        userInfo.setName(localPort + "----" + userInfo.getName());
        userInfo.setSex(localPort + "----" + userInfo.getSex());

        System.out.println("resp, userInfo " + userInfo + ", port = " + localPort);
        return userInfo;
    }
}
